define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'finance/withdrawal/index' + location.search,
                    add_url: 'finance/withdrawal/add',
                    edit_url: 'finance/withdrawal/edit',
                    del_url: 'finance/withdrawal/del',
                    multi_url: 'finance/withdrawal/multi',
                    import_url: 'finance/withdrawal/import',
                    table: 'withdrawal',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate:false},
                        {field: 'log_sn', title: __('提现编号'), operate:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'oktime', title: __('Oktime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'type', title: __("Type"), searchList: {"1":__('银行卡'),"2":__('支付宝')}, formatter: Table.api.formatter.label},
                        // {field: 'ip', title: __('Ip'), operate: false},
                        {field: 'personal.account', title: __('Personal.account'), operate: 'LIKE'},
                        {field: 'name', title: __('真实姓名'), operate: 'LIKE'},
                        {field: 'number', title: __('Number'), operate: 'LIKE'},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'fee', title: __('Fee'), operate:false},
                        {field: 'real_money', title: __('实际打款'), operate:false},
                        {field: 'status', title: __("Status"), searchList: {"0":__('审核中'),"1":__('通过'), "2":__('驳回')}, operate: 'FIND_IN_SET', formatter: Table.api.formatter.label},
                        {field: 'order_id', title: __('支付宝返回订单号'), operate:'LIKE',cellStyle: {css: {"max-width": "134px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}},
                        {field: 'pay_fund_order_id', title: __('支付宝资金流水号'), operate:'LIKE',cellStyle: {css: {"max-width": "134px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}},
                        // {field: 'out_biz_no', title: __('商户订单号'), operate:'LIKE'},
                        // {field: 'balance', title: __('Balance'), operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
